package com.itbbs.exception;

import com.itbbs.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author ysk
 * @version 1.0.1
 * @Description 自定义全局异常类
 * @createTime 2021年06月15日 12:56:00
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(CustomizeException.class)
    @ResponseBody
    public Result err(CustomizeException e){
        return Result.fail(e.getResultCodeEnum());
    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result err(Exception e){
        e.printStackTrace();
        return Result.fail();
    }
}
